#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageToVTKImageFilter.h"
#include "vtkImageViewer2.h"
#include "vtkRenderWindowInteractor.h"
// 解决 Error: no override found for 'vtkImageMapper'.
#include "vtkAutoInit.h"
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);

int main(int argc, char **argv)
{
    typedef itk::Image<unsigned short, 2> ImageType;
    typedef itk::ImageFileReader<ImageType> ReaderType;   //图像读取类
    typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;  //VTK和ITK链接器

    ReaderType::Pointer reader = ReaderType::New();
    ConnectorType::Pointer connector = ConnectorType::New();
    reader->SetFileName("/works/yd_datatest/Lena.png");
    connector->SetInput(reader->GetOutput());
    connector->Update();

    vtkImageViewer2 *viewer = vtkImageViewer2::New();
    vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New();
    viewer->SetInputData(connector->GetOutput());
    viewer->SetupInteractor(interactor);
    viewer->SetColorWindow(255); //设置窗宽
    viewer->SetColorLevel(128);   //设置窗位
    viewer->Render();
    interactor->Initialize();
    interactor->Start();

    return EXIT_SUCCESS;
}
